package com.bj58.data.emailreports.controllers;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.bj58.data.emailreports.model.NetflowWRData;
import com.bj58.data.emailreports.service.NetflowMonthReportService;
import com.bj58.data.emailreports.utils.DateUtil;
import com.bj58.data.emailreports.utils.EmailReportUtil;
import com.bj58.data.emailreports.utils.MailUtil;
import com.bj58.data.emailreports.utils.MyStore;
import com.bj58.data.emailreports.utils.ResourcesUtil;
import com.bj58.data.emailreports.utils.VelocityTools;
import com.bj58.groupbuy.service.locator.ServiceLocator;
import com.bj58.groupbuy.util.PathUtil;

/**流量数据分析月报
 * @author guoxue
 *
 */
public class NetflowMonthReportController {
	private NetflowMonthReportService netflowMonthReportService= ServiceLocator.get(NetflowMonthReportService.class);
	private EmailReportUtil eru = new EmailReportUtil();
	
	private String[] business_58={"all","fangchan","zhaopin","huangye","ershouche","ershouchuangxin","ershoutuiguang"};
	private String[] business_ganji={"all","fangchan","zhaopin","huangye","ershouche","ershou"};
	
	private String[] source_58pc={"all","ziyou","sem","seo","guanggaoxilie","lianmeng","qita"};
	private String[] source_58m={"all","ziyou","sem","seo","qita","fufeiliulanqi","fufeiqita","shoujiqq","momo","weixilie","lianmeng"};	
	private String[] source_ganji={"all","ziyou","sem","seo","fufei","qita"};
	
	
	/**第一部分  全站 - 全站流量及运营数据
	 * @param searchDate
	 * @return
	 */
	public String monthReportPartOne(String searchDate){
		try {
			//读取模板内容
			String filepath =PathUtil.getWFNamespaceFolder()+"/emailtemp/NetflowMonthReport.html";
			String templateContext = ResourcesUtil.getTemByPath(filepath);
			//渲染MAP
			Map<String,Object> conMap = new HashMap<String,Object>();
			//查询日期
			Date  sDate = DateUtil.strToDate(searchDate, "yyyy-MM-dd");
			String today = DateUtil.getStringDate(sDate,"yyyy-MM-dd");//查询日期（今）
			today = DateUtil.firstDayMonthBefore(today, "yyyy-MM-dd",0);//把今天换算成 当月第一天
			
			String lastmonthfirstday = DateUtil.firstDayMonthBefore(today, "yyyy-MM-dd",1);//查询日期（上月第一天）
			String lastyearfirstday = DateUtil.firstDayMonthBefore(today, "yyyy-MM-dd",12);//查询日期（去年本月第一天）
			
			List<String> dateList = new ArrayList<String>();
			dateList.add(today);dateList.add(lastmonthfirstday);dateList.add(lastyearfirstday);
		
			conMap.put("today", today.replaceAll("-", "."));
			conMap.put("lastmonthfirstday", lastmonthfirstday.replaceAll("-", "."));
			conMap.put("lastyearfirstday", lastyearfirstday.replaceAll("-", "."));
			
			conMap.put("curmonth", today.substring(0,7).replaceAll("-", "."));
						
			List<String> showCols = new ArrayList<String>(); //同比环比计算指标集
			List<String> percentList = new ArrayList<String>();//百分比指标集
					
			String[] cate={"58","ganji"};
		
			showCols.clear();
			showCols.add("vppv");showCols.add("vppvZb");showCols.add("uv");showCols.add("uvZb");
			showCols.add("pv");showCols.add("pvZb");showCols.add("vppv_uv");		
			percentList.clear();
			percentList.add("vppvZb");percentList.add("uvZb");percentList.add("pvZb");
			
			
			//全站PC端流量数据				
			Map<String,List<NetflowWRData>> NMRPCBusiDataMap = netflowMonthReportService.getNMRPlatformDataMap(dateList,"pc",business_58,business_ganji);
			List<String> NMRPCBusiData=new ArrayList<String>();
			
			for(String c:cate){
				
				if(NMRPCBusiDataMap.containsKey(c)){
					List<NetflowWRData> tempList = NMRPCBusiDataMap.get(c);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", percentList, dateList);
					
					showData(NMRPCBusiData,dataList,c);
					
				}
			}	
			conMap.put("NMRPCBusiData", NMRPCBusiData);
					
			
			//全站M端流量数据					
			Map<String,List<NetflowWRData>> NMRMBusiDataMap = netflowMonthReportService.getNMRPlatformDataMap(dateList,"m",business_58,business_ganji);
			List<String> NMRMBusiData=new ArrayList<String>();
			
			for(String c:cate){
				
				if(NMRMBusiDataMap.containsKey(c)){
					List<NetflowWRData> tempList = NMRMBusiDataMap.get(c);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", percentList, dateList);
					
					showData(NMRMBusiData,dataList,c);
					
				}
			}	
			conMap.put("NMRMBusiData", NMRMBusiData);
			
			
			//全站APP端流量数据					
			Map<String,List<NetflowWRData>> NMRAPPBusiDataMap = netflowMonthReportService.getNMRPlatformDataMap(dateList,"app",business_58,business_ganji);
			List<String> NMRAPPBusiData=new ArrayList<String>();
			
			for(String c:cate){
				
				if(NMRAPPBusiDataMap.containsKey(c)){
					List<NetflowWRData> tempList = NMRAPPBusiDataMap.get(c);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", percentList, dateList);
					
					showData(NMRAPPBusiData,dataList,c);
					
				}
			}	
			conMap.put("NMRAPPBusiData", NMRAPPBusiData);


			//全站流量数据  前面pc m app的加和		
			Map<String,List<NetflowWRData>> NMRBusiDataMap =  netflowMonthReportService.getNMRALLDataMap(dateList,NMRPCBusiDataMap,NMRMBusiDataMap,NMRAPPBusiDataMap);

            List<String> NMRBusiData=new ArrayList<String>();		
			for(String c:cate){
				
				if(NMRBusiDataMap.containsKey(c)){
					List<NetflowWRData> tempList = NMRBusiDataMap.get(c);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", null, dateList);
					
					showData(NMRBusiData,dataList,c);
					
				}
			}	
			conMap.put("NMRBusiData", NMRBusiData);
			
			
			//流量PC来源数据数据	
			Map<String,String> sourceMap_58pc = new HashMap<String,String>();
			sourceMap_58pc.put("all", "source1 in ('all')");
			sourceMap_58pc.put("ziyou", "source1 in ('直接访问','站内引荐')");
			sourceMap_58pc.put("guanggaoxilie", "source1 in ('广告系列')");
			sourceMap_58pc.put("lianmeng", "source1 in ('联盟')");
			sourceMap_58pc.put("sem", "source1 in ('SEM')");
			sourceMap_58pc.put("seo", "source1 in ('SEO')");
			sourceMap_58pc.put("qita", "source1 in ('其他')");
					
			Map<String,String> sourceMap_ganji = new HashMap<String,String>();
			sourceMap_ganji.put("all", "'-'");
			sourceMap_ganji.put("ziyou", "'self'");
			sourceMap_ganji.put("fufei", "'tg'");
			sourceMap_ganji.put("sem", "'sem'");
			sourceMap_ganji.put("seo", "'seo'");
			sourceMap_ganji.put("qita", "'other'");
			
			showCols.clear();
			showCols.add("vppv");showCols.add("vppvZb");showCols.add("uv");showCols.add("uvZb");showCols.add("vppv_uv");			
			percentList.clear();
			percentList.add("vppvZb");percentList.add("uvZb");
			
			Map<String,List<NetflowWRData>> NMRPCSourceDataMap = netflowMonthReportService.getNMRSourceDataMap(dateList,sourceMap_58pc,sourceMap_ganji,"pc","all");
			List<String> NMRPCSourceData=new ArrayList<String>();
			
			for(String c:cate){
				
				if(NMRPCSourceDataMap.containsKey(c)){
					List<NetflowWRData> tempList = NMRPCSourceDataMap.get(c);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", percentList, dateList);
					
					showData_source(NMRPCSourceData,dataList,c,"pc");
					
				}
			}	
			conMap.put("NMRPCSourceData", NMRPCSourceData);
			
	
			//流量M来源数据数据	
			Map<String,String> sourceMap_58m = new HashMap<String,String>();
			sourceMap_58m.put("all", "source1 ='all' and source2='all'");
			sourceMap_58m.put("ziyou", "source1 = 'ziyou' and source2='all'");
			sourceMap_58m.put("sem", "source1 = 'qd' and source2 = 'sem' and source3='all'");
			sourceMap_58m.put("seo", "source1 ='sou' and source2='all'");
			sourceMap_58m.put("qita",  "source1 ='other' and source2='all'");		
			sourceMap_58m.put("fufeiliulanqi", "source1 = 'qd' and source2 = 'fufeiliulanqi' and source3='all'");
			sourceMap_58m.put("fufeiqita", "source1 = 'qd' and source2 = 'fufeiqita' and source3='all'");
			sourceMap_58m.put("shoujiqq", "source1 = 'shoujiqq' and source2='all'");
			sourceMap_58m.put("momo", "source1 = 'momo' and source2='all'");
			sourceMap_58m.put("weixilie",  "source2 like '%wei%'");
			sourceMap_58m.put("lianmeng", "source1 = 'qd' and source2 = 'lianmeng' and source3='all'");
					
			showCols.clear();
			showCols.add("vppv");showCols.add("vppvZb");showCols.add("uv");showCols.add("uvZb");showCols.add("vppv_uv");			
			percentList.clear();
			percentList.add("vppvZb");percentList.add("uvZb");
			
			Map<String,List<NetflowWRData>> NMRMSourceDataMap = netflowMonthReportService.getNMRSourceDataMap(dateList,sourceMap_58m,sourceMap_ganji,"m","all");
			List<String> NMRMSourceData=new ArrayList<String>();
			
			for(String c:cate){
				
				if(NMRMSourceDataMap.containsKey(c)){
					List<NetflowWRData> tempList = NMRMSourceDataMap.get(c);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", percentList, dateList);
					
					showData_source(NMRMSourceData,dataList,c,"m");
					
				}
			}	
			conMap.put("NMRMSourceData", NMRMSourceData);
			
			
			return VelocityTools.render(templateContext, conMap);
		} catch (Exception e) {
			e.printStackTrace();
			return "";
		}
	}
	
	/**第二部分  黄页 招聘 二手创新（只有58）- 流量及运营数据
	 * @param searchDate
	 * @return
	 */
	public String monthReportPartTwo(String searchDate,String business){
		try {
			//读取模板内容
			String filepath =PathUtil.getWFNamespaceFolder()+"/emailtemp/NetflowMonthReport.html";
			String templateContext = ResourcesUtil.getTemByPath(filepath);
			//渲染MAP
			Map<String,Object> conMap = new HashMap<String,Object>();
			//查询日期
			Date  sDate = DateUtil.strToDate(searchDate, "yyyy-MM-dd");
			String today = DateUtil.getStringDate(sDate,"yyyy-MM-dd");//查询日期（今）
			today = DateUtil.firstDayMonthBefore(today, "yyyy-MM-dd",0);//把今天换算成 当月第一天
			
			String lastmonthfirstday = DateUtil.firstDayMonthBefore(today, "yyyy-MM-dd",1);//查询日期（上月第一天）
			String lastyearfirstday = DateUtil.firstDayMonthBefore(today, "yyyy-MM-dd",12);//查询日期（去年本月第一天）
			
			List<String> dateList = new ArrayList<String>();
			dateList.add(today);dateList.add(lastmonthfirstday);dateList.add(lastyearfirstday);
		
			conMap.put("today", today.replaceAll("-", "."));
			conMap.put("lastmonthfirstday", lastmonthfirstday.replaceAll("-", "."));
			conMap.put("lastyearfirstday", lastyearfirstday.replaceAll("-", "."));
				
			conMap.put("curmonth", today.substring(0,7).replaceAll("-", "."));
			
			List<String> showCols = new ArrayList<String>(); //同比环比计算指标集
			List<String> percentList = new ArrayList<String>();//百分比指标集
					
			String[] cate={"58","ganji"};
			conMap.put("business", MyStore.busilineTran(business));
		
			
			//流量及运营数据		
			showCols.clear();
			showCols.add("vppv");showCols.add("vppvZb");showCols.add("uv");showCols.add("uvZb");
			showCols.add("pv");showCols.add("pvZb");showCols.add("vppv_uv");
			
			percentList.clear();
			percentList.add("vppvZb");percentList.add("uvZb");percentList.add("pvZb");
	
			Map<String,List<NetflowWRData>> HYALLDataMap = netflowMonthReportService.getNMRBusiDataMap(dateList,business);
			List<String> ALLData=new ArrayList<String>();
			for(String c:cate){
				
				if(HYALLDataMap.containsKey(c)){
					List<NetflowWRData> tempList = HYALLDataMap.get(c);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", percentList, dateList);
					
					showData_platform(ALLData,dataList);
					
				}
			}	
			conMap.put("ALLData", ALLData);
			
			
			//PC端流量数据					
			Map<String,String> sourceMap_58pc = new HashMap<String,String>();
			sourceMap_58pc.put("all", "source1 in ('all')");
			sourceMap_58pc.put("ziyou", "source1 in ('直接访问','站内引荐')");
			sourceMap_58pc.put("guanggaoxilie", "source1 in ('广告系列')");
			sourceMap_58pc.put("lianmeng", "source1 in ('联盟')");
			sourceMap_58pc.put("sem", "source1 in ('SEM')");
			sourceMap_58pc.put("seo", "source1 in ('SEO')");
			sourceMap_58pc.put("qita", "source1 in ('其他')");
					
			Map<String,String> sourceMap_ganji = new HashMap<String,String>();
			sourceMap_ganji.put("all", "'-'");
			sourceMap_ganji.put("ziyou", "'self'");
			sourceMap_ganji.put("fufei", "'tg'");
			sourceMap_ganji.put("sem", "'sem'");
			sourceMap_ganji.put("seo", "'seo'");
			sourceMap_ganji.put("qita", "'other'");
			
			showCols.clear();
			showCols.add("vppv");showCols.add("vppvZb");showCols.add("uv");showCols.add("uvZb");showCols.add("vppv_uv");			
			percentList.clear();
			percentList.add("vppvZb");percentList.add("uvZb");
			
			Map<String,List<NetflowWRData>> HYPCSourceDataMap = netflowMonthReportService.getNMRSourceDataMap(dateList,sourceMap_58pc,sourceMap_ganji,"pc",business);
			List<String> PCSourceData=new ArrayList<String>();
			
			for(String c:cate){
				
				if(HYPCSourceDataMap.containsKey(c)){
					List<NetflowWRData> tempList = HYPCSourceDataMap.get(c);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", percentList, dateList);
					
					showData_source(PCSourceData,dataList,c,"pc");
					
				}
			}	
			conMap.put("PCSourceData", PCSourceData);
				
			
			//流量M来源数据数据	
			Map<String,String> sourceMap_58m = new HashMap<String,String>();
			sourceMap_58m.put("all", "source1 ='all' and source2='all'");
			sourceMap_58m.put("ziyou", "source1 = 'ziyou' and source2='all'");
			sourceMap_58m.put("sem", "source1 = 'qd' and source2 = 'sem' and source3='all'");
			sourceMap_58m.put("seo", "source1 ='sou' and source2='all'");
			sourceMap_58m.put("qita",  "source1 ='other' and source2='all'");		
			sourceMap_58m.put("fufeiliulanqi", "source1 = 'qd' and source2 = 'fufeiliulanqi' and source3='all'");
			sourceMap_58m.put("fufeiqita", "source1 = 'qd' and source2 = 'fufeiqita' and source3='all'");
			sourceMap_58m.put("shoujiqq", "source1 = 'shoujiqq' and source2='all'");
			sourceMap_58m.put("momo", "source1 = 'momo' and source2='all'");
			sourceMap_58m.put("weixilie",  "source2 like '%wei%'");
			sourceMap_58m.put("lianmeng", "source1 = 'qd' and source2 = 'lianmeng' and source3='all'");
					
			showCols.clear();
			showCols.add("vppv");showCols.add("vppvZb");showCols.add("uv");showCols.add("uvZb");showCols.add("vppv_uv");			
			percentList.clear();
			percentList.add("vppvZb");percentList.add("uvZb");
			
			Map<String,List<NetflowWRData>> HYMSourceDataMap = netflowMonthReportService.getNMRSourceDataMap(dateList,sourceMap_58m,sourceMap_ganji,"m",business);
			List<String> MSourceData=new ArrayList<String>();
			
			for(String c:cate){
				
				if(HYMSourceDataMap.containsKey(c)){
					List<NetflowWRData> tempList = HYMSourceDataMap.get(c);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", percentList, dateList);
					
					showData_source(MSourceData,dataList,c,"m");
					
				}
			}	
			conMap.put("MSourceData", MSourceData);
						
			
			return VelocityTools.render(templateContext, conMap);
		} catch (Exception e) {
			e.printStackTrace();
			return "";
		}
	}
	
	
	/**第三部分  二手创新（只有58）- 流量及运营数据
	 * @param searchDate
	 * @return
	 */
	public String monthReportPartThree(String searchDate){
		try {
			//读取模板内容
			String filepath =PathUtil.getWFNamespaceFolder()+"/emailtemp/NetflowMonthReport.html";
			String templateContext = ResourcesUtil.getTemByPath(filepath);
			//渲染MAP
			Map<String,Object> conMap = new HashMap<String,Object>();
			//查询日期
			Date  sDate = DateUtil.strToDate(searchDate, "yyyy-MM-dd");
			String today = DateUtil.getStringDate(sDate,"yyyy-MM-dd");//查询日期（今）
			today = DateUtil.firstDayMonthBefore(today, "yyyy-MM-dd",0);//把今天换算成 当月第一天
			String today_cate = DateUtil.lastDayMonthBefore(today, "yyyy-MM-dd",0);//把今天换算成 当月最后一天
			
			String lastmonthfirstday = DateUtil.firstDayMonthBefore(today, "yyyy-MM-dd",1);//查询日期（上月第一天）
			String lastyearfirstday = DateUtil.firstDayMonthBefore(today, "yyyy-MM-dd",12);//查询日期（去年本月第一天）
			
			List<String> dateList = new ArrayList<String>();
			dateList.add(today);dateList.add(today_cate);dateList.add(lastmonthfirstday);dateList.add(lastyearfirstday);
		
			conMap.put("today", today.replaceAll("-", "."));
			conMap.put("lastmonthfirstday", lastmonthfirstday.replaceAll("-", "."));
			conMap.put("lastyearfirstday", lastyearfirstday.replaceAll("-", "."));
				
			conMap.put("curmonth", today.substring(0,7).replaceAll("-", "."));
			
			List<String> showCols = new ArrayList<String>(); //同比环比计算指标集
			List<String> percentList = new ArrayList<String>();//百分比指标集
					
			conMap.put("business", "二手创新");
				
	/*		
			//流量及运营数据		
			showCols.clear();
			showCols.add("vppv");showCols.add("vppvZb");showCols.add("uv");showCols.add("uvZb");
			showCols.add("pv");showCols.add("pvZb");showCols.add("vppv_uv");
			
			percentList.clear();
			percentList.add("vppvZb");percentList.add("uvZb");percentList.add("pvZb");
	
			List<NetflowWRData> ESCXDataList = netflowMonthReportService.getNMRESCXDataList(dateList);
			List<String> ESCXData=new ArrayList<String>();
			
			List<String> dataList = eru.conformDataTypeEight(ESCXDataList, NetflowWRData.class, "type", showCols, "statDate", percentList, dateList);			
			showData_platform(ESCXData,dataList);
			
			conMap.put("ESCXData", ESCXData);
		
			
			//PC端流量数据					
			Map<String,String> sourceMap_58pc = new HashMap<String,String>();
			sourceMap_58pc.put("all", "source1 in ('all')");
			sourceMap_58pc.put("ziyou", "source1 in ('直接访问','站内引荐')");
			sourceMap_58pc.put("guanggaoxilie", "source1 in ('广告系列')");
			sourceMap_58pc.put("lianmeng", "source1 in ('联盟')");
			sourceMap_58pc.put("sem", "source1 in ('SEM')");
			sourceMap_58pc.put("seo", "source1 in ('SEO')");
			sourceMap_58pc.put("qita", "source1 in ('其他')");

			showCols.clear();
			showCols.add("vppv");showCols.add("vppvZb");showCols.add("uv");showCols.add("uvZb");showCols.add("vppv_uv");			
			percentList.clear();
			percentList.add("vppvZb");percentList.add("uvZb");
			
			List<NetflowWRData> ESCXPCSourceDataList = netflowMonthReportService.getESCXSourceDataList(dateList,sourceMap_58pc,"pc");
			List<String> ESCXPCSourceData=new ArrayList<String>();
	
			List<String> dataList2 = eru.conformDataTypeEight(ESCXPCSourceDataList, NetflowWRData.class, "type", showCols, "statDate", percentList, dateList);				
			showData_source(ESCXPCSourceData,dataList2,"58","pc");					
				
			conMap.put("ESCXPCSourceData", ESCXPCSourceData);
				
	*/			
			//流量M来源数据数据	
			Map<String,String> sourceMap_58m = new HashMap<String,String>();
			sourceMap_58m.put("all", "source1 ='all' and source2='all'");
			sourceMap_58m.put("ziyou", "source1 = 'ziyou' and source2='all'");
			sourceMap_58m.put("sem", "source1 = 'qd' and source2 = 'sem' and source3='all'");
			sourceMap_58m.put("seo", "source1 ='sou' and source2='all'");
			sourceMap_58m.put("qita",  "source1 ='other' and source2='all'");		
			sourceMap_58m.put("fufeiliulanqi", "source1 = 'qd' and source2 = 'fufeiliulanqi' and source3='all'");
			sourceMap_58m.put("fufeiqita", "source1 = 'qd' and source2 = 'fufeiqita' and source3='all'");
			sourceMap_58m.put("shoujiqq", "source1 = 'shoujiqq' and source2='all'");
			sourceMap_58m.put("momo", "source1 = 'momo' and source2='all'");
			sourceMap_58m.put("weixilie",  "source2 like '%wei%'");
			sourceMap_58m.put("lianmeng", "source1 = 'qd' and source2 = 'lianmeng' and source3='all'");
					
			showCols.clear();
			showCols.add("vppv");showCols.add("vppvZb");showCols.add("uv");showCols.add("uvZb");showCols.add("vppv_uv");			
			percentList.clear();
			percentList.add("vppvZb");percentList.add("uvZb");
			
			List<NetflowWRData> ESCXMSourceDataList = netflowMonthReportService.getESCXSourceDataList(dateList,sourceMap_58m,"m");
			List<String> ESCXMSourceData=new ArrayList<String>();
							
			List<String> dataList3 = eru.conformDataTypeEight(ESCXMSourceDataList, NetflowWRData.class, "type", showCols, "statDate", percentList, dateList);			
			//change100(dataList3);
			showData_source(ESCXMSourceData,dataList3,"58","m");
		
			conMap.put("ESCXMSourceData", ESCXMSourceData);
					
			
			return VelocityTools.render(templateContext, conMap);
		} catch (Exception e) {
			e.printStackTrace();
			return "";
		}
	}
	
	public void change100(List<String> dataList)throws Exception {
		
		for(int i=0;i<dataList.size();i++){
			
			String s=dataList.get(i);
			String a[]=s.split(";");
			
			//ganji分来源没有月同比

			if(a[0].contains("ganji"))
			{
				if(a[3].contains("100%"))
					a[3]="--";
					
				if(a[9].contains("100%"))
					a[9]="--";
					
				s=StringUtils.join(a, ";");
						
			}
		
			dataList.set(i, s);
			
		}
	}
		

	//表头左侧放 58 赶集 
	public void showData(List<String> rslist,List<String> dataList,String cate)throws Exception {
			
		String business[]={};
		
		if(cate.equals("58")){
			business=business_58;			
		}else{
			business=business_ganji;	
		}	
		
		for(String busi:business)
		{
			for(String s:dataList){
				String a=s.split(";")[0];
				a=a.substring(s.lastIndexOf("_")+1,a.length());	
				
				if(a.equals(busi))//如果直接contain，ershou和二手车会混淆
				{											
					a=a.replaceAll(busi, MyStore.busilineTran(busi));
					s=a+s.substring(s.indexOf(";"));
					
					rslist.add(s);
					break;
				}
			}
		}	
			
	}
	
	public void showData_source(List<String> rslist,List<String> dataList,String cate,String platform)throws Exception {
	
		String sourceArray[]={};
		
		if(cate.equals("58") && platform.equals("pc")){
			sourceArray=source_58pc;			
		}else if(cate.equals("58") && platform.equals("m")){
			sourceArray=source_58m;		
		}else if(cate.equals("ganji")){
			sourceArray=source_ganji;		
		}					
			
		for(String source:sourceArray)
		{
			for(String s:dataList){
				String a=s.split(";")[0];
				a=a.substring(s.lastIndexOf("_")+1,a.length());	
				
				if(a.equals(source))
				{											
					a=a.replaceAll(source, MyStore.sourceTran(source));
					s=a+s.substring(s.indexOf(";"));
					
					rslist.add(s);
					break;
				}
			}
		}		
	}	
	
	public void showData_platform(List<String> rslist,List<String> dataList)throws Exception {
		
		String[] platform={"all","pc","m","app"};
	
		for(String p:platform)
		{
			for(String s:dataList){
				String a=s.split(";")[0];
				a=a.substring(s.lastIndexOf("_")+1,a.length());	
				
				if(a.equals(p))
				{											
					a=a.replaceAll(p, MyStore.platformTran(p));
					s=a+s.substring(s.indexOf(";"));
					
					rslist.add(s);
					break;
				}
			}
		}		
	}	

	
	public static void main(String[] args) {
		try {
			String searchDate="2016-02-21 ";
			NetflowMonthReportController test = new NetflowMonthReportController();
			//String content = test.monthReportPartOne(searchDate);
			//String content = test.monthReportPartTwo(searchDate,"huangye");
			//String content = test.monthReportPartTwo(searchDate,"zhaopin");
			String content = test.monthReportPartThree(searchDate);
			
			if(!"".equals(content)){
//				String text="流量数据周报测试  "+searchDate;
//				MailUtil.javaMailSend(text, content, "guoxue@58.com",null);
				
				String text="流量数据月报  "+searchDate;
				MailUtil.javaMailSend(text, content, "guoxue@58.com",null);
			}else{
				//邮件报警
//				content = "流量数据周报报错！";
//		    	MailUtil.javaMailSend("email report error", content, "guoxue@58.com",null);
//		    	Map<String,String> telMap=new HashMap<String,String>();
//		    	telMap.put("15726690526","email report error:"+content);
//		    	SubmitSms.submitMsg(telMap);
			
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
